#ifndef FORM_PLOT_DLG_H
#define FORM_PLOT_DLG_H

// add necessary includes here
#include "ui/defines/global.h"

class QCustomPlot;

namespace Ui {
class FormPlotDlg;
}

class FormPlotDlg : public QWidget
{
    Q_OBJECT

public:
    // The default destructor
    explicit FormPlotDlg(QWidget *parent = nullptr);

    // The default destructor
    ~FormPlotDlg();

    // Select chart type and initialize style
    void selectChartType(int nChartType);

    // Clear the chart data (melting)
    void clearChartData(int nChartType, double dAxisMinX = 0, double dAxisMaxX = 0);

    // Get the chart data
    int getChartData(int nChartType, QMap<unsigned int, QVector<QPointF>> &mapValue);

    // Set the chart data by vector
    void setChartData(int nLineIdx, QMap<unsigned int, QVector<QPointF>> &mapValue, bool bUpdateRange = false);

    // Update the range of chart
    void updateChartRange(int nChartType);

    // Attach data into the chart (only for heati testing)
    void addChartData(int nChartType, int nLineIdx, float fValue);

    // Attach data into the chart (only for fluoresence & melting testing)
    void addChartData(int nChartType, int nLineIdx, int nCycleIdx, float fValue, float fAxisMinX = 0, float fAxisMaxX = 0, float fAxisStep = 1);

protected:
    // Triggers an event before it is switch language
    void changeEvent(QEvent *event);

signals:
    // Set lines status (show/hide)
    void signalShowLegendControl(int nChartType, int nChartAttribute, QStringList lstAxisRange);

private slots:
    void on_pushButton_Move_clicked(bool checked);

    void on_pushButton_Reset_clicked();

    void on_pushButton_LegendControl_clicked();

    // Get the reply message from the child window
    void slotRespondInfoFromDlg(int nChartType, int nChartAttribute, int nLedFlag, QStringList lstContent);

    void slotSelectionChanged();

private:
    // After constructing object, initialize the object
    void _initialze();

    // Init the window style
    void _initUi();

private:
    Ui::FormPlotDlg *ui;

    QCustomPlot         *m_pCustomPlot = nullptr;
    int                 m_nChartType = E_CT_TEMP;
    mutable double      m_dAxisMinX = 0;
    mutable double      m_dAxisMaxX = 0;
    mutable double      m_dAxisMinY = 0;
    mutable double      m_dAxisMaxY = 0;
};

#endif // FORM_PLOT_DLG_H
